package ccapp;

import java.util.Calendar;
import java.util.List;

import frmsystem.Entry;
import frmsystem.IAccount;
import frmsystem.IEntry;

public class Deposit extends Entry{

	public Deposit(IAccount acc){
		super(acc);		
	}	
	
	public void execute(){
		account.setBalance(account.getBalance() + amount);
	}
	
	public String toString(){
		return "Deposit : $ " + String.valueOf(amount) + " , " + date.toString();
		
	}
	public double getTotal(List<IEntry> entries, Calendar calendarFirst, Calendar calendarLast){
		double total = 0;
		for(IEntry entry : entries){
			if(calendarFirst.after(entry.getDate()) && calendarLast.before(entry.getDate())){
				if(entry.getClass().equals((this.getClass()))){ 
					total += entry.getAmount();
				}
				   			
			}
		}
		return total;
		
	}
	
}
